/*
 * @Author: aggfb 714740235@qq.com
 * @Date: 2024-05-19 08:16:41
 * @LastEditors: aggfb 714740235@qq.com
 * @LastEditTime: 2024-05-22 20:58:39
 * @FilePath: \label_rack_control\firmware\model\ui_screen\ui_screen.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef __UI_SCREEN_H
#define __UI_SCREEN_H

#include "stdio.h"	
#include "bsp_sys.h" 
#include "bsp_usart.h"	
#include "ringbuffer.h"  

#define RING_BUFF_SIZE 256U /* 环形队列长度 */
#define FRAME_SIZE 32 /* 帧长度 */

typedef struct _ui_assembly {
    uint8_t state; /* 锁屏状态 */
    uint16_t current_speed; /* 当前速度 */
    uint8_t cmd_rest_state; /* 控制--->复位 */
    uint8_t feed_state; /* 进料状态 */
} ui_assembly_t;

typedef struct _ui_screen {
    /* 解析相关 */
    uint8_t buff[FRAME_SIZE];
    uint8_t size;
    uint8_t cmd_id;
    uint8_t sum8;

    /* 公共数据 */
    ui_assembly_t assembly;
    ring_buf_t ring_buff;
    void (*init)(void);
    void (*write)(uint32_t);
    uint32_t (*read)(void);
    uint32_t (*ctrl)(uint8_t);
    uint64_t key_over_time;
} ui_screen_t;


extern ui_screen_t* ui_screen_dev(void);
extern void ui_screen_init(void);
extern void ui_screen_recv_handle(void);

extern void ui_screen_sned_production_quantity(uint32_t num);/* 发送生产数量 */
extern void ui_screen_sned_offset(uint32_t num);/* 发送offset */
extern void ui_screen_sned_speed(uint32_t num);/* 发送speed */
extern void ui_screen_sned_run_mode(uint32_t num); /* 手动-自动模式 */

extern void ui_screen_sned_fault_type(uint32_t num); /* 故障类型 */

#endif


